﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace RytmSerca.Validators
{
    class PositiveNumberValidationRule : ValidationRule
    {
        int _minimum;

        public int Minimum
        {
            get { return _minimum; }
            set { _minimum = value; }
        }
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            var str = value.ToString();
            double val;
            if (!double.TryParse(str, out val) || val < _minimum)
                return new ValidationResult(false, "Wartość musi być liczbą dodatnią.");
            return new ValidationResult(true, null);
        }
    }
}
